package com.atguigu.a_stringbuilder;

public class Demo {
    public static void main(String[] args) {
        //创建sb对象
        StringBuilder sb1 = new StringBuilder();
        System.out.println("sb1.length() = " + sb1.length());//长度 : 0
        System.out.println("sb1.capacity() = " + sb1.capacity());//容量 : 16

        sb1.append("World");

        System.out.println("sb1.length() = " + sb1.length());//长度 : 5
        System.out.println("sb1.capacity() = " + sb1.capacity());//容量 : 16

        System.out.println("sb1 = " + sb1);

        System.out.println("-----------------------------------");

        StringBuilder sb2 = new StringBuilder("Hello");
        System.out.println("sb2.length() = " + sb2.length());//长度 : 5
        System.out.println("sb2.capacity() = " + sb2.capacity());//容量 : 16 + 5

        sb2.append("World");

        System.out.println("sb2.length() = " + sb2.length());//长度 : 10
        System.out.println("sb2.capacity() = " + sb2.capacity());//容量 : 21

        System.out.println("sb2 = " + sb2);
        System.out.println("-----------------------------------");

        //StringBuilder sb3 = "Hello";
    }
}
